<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>取快递</title>
	<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/qu_scss.css">
	<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/reset.css">
	<script src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.1.min.js"></script>
	<script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<style>
        *{
            a:active{
                text-decoration:none;
            }
            a:link{
                text-decoration:none;
            }
            a:visited{
                text-decoration:none;
            }
            a:hover{
                text-decoration:none;
            }
        }
	</style>
</head>
<body>
	<nav>
        <a style="text-decoration: none" href="<?php echo SITE_PATH ?>work/bexpress/index"><span>寄快递</span></a>
        <a style="text-decoration: none" href="<?php echo SITE_PATH ?>work/bexpress/qu"><span>取快递</span></a>
        <a style="text-decoration: none" href="<?php echo SITE_PATH ?>work/bexpress/wu"><span>物流托运</span></a>
		<div class="gongneng">
			<p>功能</p>
			<img src="<?php echo IMG_PATH ?>bdkd/img/xiala@2x.png" alt="">
			<div class="kuaidigongsi" style="display:none";>
				<ul>
                    <a><div onclick="price()"><li>价格查询</li></div></a>
                    <a><div onclick="time()"><li>时效查询</li></div></a>
                    <a><div onclick="jx()"><li>禁寄物品</li></div></a>
                    <a><div onclick="sm()"><li>免责声明</li></div></a>
				</ul>
			</div>
		</div>
	</nav>
    <input type="hidden" name="num" value="<?php
    if(!empty($num)){
        echo $num;
    }
    //echo $num;
    ?>">
	<a class="fajianren" onclick="dizhi()">
		<div class="yuan">
			<div class="dian"></div>
		</div>
        <input type="hidden" name="gname" id="gname1" value="" >
        <input type="hidden" name="gphone" id="gphone1" value="" >
		<div class="fajianrenxinxi">
			<input style="background:#fff" type="text" disabled="disabled" class="rjx-fajianren rjx-fjr1" placeholder="取件人信息" value="取件人信息" >
			<textarea id="gaddress" style="background:#fff" name="text" disabled="disabled" placeholder="请输入详细的取件人信息,以便我们更好地完成您的需要" value="" class="rjx-fjrxx"></textarea>
		</div>
	</a>
	<div class="zjjd">
		<a class="shoujianren" style="text-decoration: none;">
			<div class="shoujianrenxinxi">
				<p>请输入您的取件信息<span>( 可直接粘贴 )</span></p>
				<textarea name="text" class="rjx-sjrxx wenben-xsd remark" placeholder="请详细说明快递所在站点名称和取件编码(此处只能填写一条取件信息)" value=""></textarea>
			</div>
		</a>
	</div>
    <div class="fucen">
        <div class="cha" onclick="guanbi()">
            <img src="<?php echo IMG_PATH ?>bdkd/img/@2x.png" height="30" width="28" alt="">
        </div>
        <p>是否确认删除订单？</p>
        <div class="qxdd" >
            确认
        </div>
    </div>
	<div class="jiahao">
		<div class="tu-jiahao">
			<img src="<?php echo IMG_PATH ?>bdkd/img/jiahao@2x.png" alt="">
		</div>
		<p>继续取件</p>
	</div>
	<div class="jiaqian">
		<div class="jiaqian-bug">
			<p>收费 : <span>3</span>元/件</p>
<!--			<div class="yugu">预估 :<div id="dv"><label></label></div><input id="bmmc" type="text" value="45.00" disabled="true">元</div>
-->            <div class="yugu">预估 :<span>--</span>元</div>

            <div class="gongji">
				<!--<div>
					共计 : <div id="gj"><label></label></div><input type="text" id="gongji" disabled="true">件
				</div>-->
				共计 : <span>--</span>件
<!--				<div class="yhq"><img class="danxuan-btn" src="--><?php //echo IMG_PATH ?><!--bdkd/img/组-@2x.png" alt="">使用优惠券</div>-->
			</div>
			
		</div>
	</div>

	<div class="fuwuxieyi">
		<div class="anniu">
			<span>
				<img class="danxuan-btn" src="<?php echo IMG_PATH ?>bdkd/img/组-@2x.png" alt="">
			</span>
			
			<span>我已阅读并同意</span>
			<a onclick="xy()">《便递服务协议》</a>
		</div>
		<div class="btn" onclick="sends()">开始取件</div>
	</div>
    <input class="xyzt" name="xyzt" type="hidden" value="">
	<script type="text/javascript">
        var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
        $(window).on('resize', function () {
            var nowClientHeight = document.documentElement.clientHeight || document.body.clientHeight;
            if (clientHeight > nowClientHeight) {
                $('body').css('margin-top','-100px').css('transition','all 0.3s ease 0s');
                $('.wenben-xsd').css('color','#333');
            }
            else {
                $('body').css('margin-top','0px').css('transition','all 0.3s ease 0s');
                $('.wenben-xsd').css('color','#333');
            }
        });
//        var qjxxArr = [];
        function sends(){


            var gname=$(" input[ name='gname' ] ").val();
            var gphone=$(" input[ name='gphone' ] ").val();
            var gaddress=$("#gaddress").val();


            var remarkArr=[];
            var remark=$('.remark');
            for(var i = 0;i<remark.length;i++){
                remarkArr[i]=remark.eq(i).val()
                // console.log(remark.eq(i).val());

            }

            var pdsftrxx = $('.wenben-xsd').val();
            console.log(pdsftrxx);
            if($('.wenben-xsd').val().length===0){
                alert('请填写取件信息');
                return false;
            }
            var i = $('.xyzt').val();
            if(i==0){
                alert('请阅读并同意《便递服务协议》');
                return false;
            }
            $.ajax({
                url:"<?php echo SITE_PATH ?>work/bexpress/getOrder",
                type:"post",
                data:{
                    'gname':gname,
                    'gphone':gphone,
                    'gaddress':gaddress,
                    'remarkArr':remarkArr

                },
                success: function(data){
                    console.log(data);
                    if(data.result==1){
                        alert('下单成功!');
                        //http://s.biandikeji.com/work/borders/untreated
                        window.location.href = '<?php echo SITE_PATH ?>work/borders/untreated';
                    }else {
                        alert(data.msg);
                    }
                },
                error: function(){
                    alert('提交失败0!');
                }

            })


//            wx.config({
//                debug: false,
//                appId: '<?php
//                    if(!empty($list['signPackage'])){
//                        echo $list['signPackage']["appId"];
//                    }
//                ?>//',
//                timestamp:'<?php
//                if(!empty($list['signPackage'])){
//                echo $list['signPackage']["timestamp"];
//            } ?>//',
//                nonceStr: '<?php
//                if(!empty($list['signPackage'])){
//                    echo $list['signPackage']["nonceStr"];
//                }
//
//                ?>//',
//                signature: '<?php
//                if(!empty($list['signPackage'])){
//                    echo $list['signPackage']["signature"];
//                }
//
//                ?>//',
//                jsApiList: [
//                    // 所有要调用的 API 都要加到这个列表中
//                    'getLocation'
//                ]
//            });
//
//            wx.ready(function () {
//                type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
//                wx.getLocation({
//                    success: function (res) {
//                        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
//                        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
//                        var speed = res.speed; // 速度，以米/每秒计
//                        var accuracy = res.accuracy; // 位置精度
//
//                        var i = $('.xyzt').val();
//                        if(i==0){
//                            alert('请阅读并同意《便递服务协议》');
//                            return false;
//                        }
//                        var gname=$(" input[ name='gname' ] ").val();
//                        var gphone=$(" input[ name='gphone' ] ").val();
//                        var gaddress='河北省廊坊市三河市燕郊镇'+$("#gaddress").val();
//
//                        // alert(gaddress);
//
//                        var remarkArr=[];
//                        var remark=$('.remark');
//                        for(var i = 0;i<remark.length;i++){
//                            remarkArr[i]=remark.eq(i).val()
//                            // console.log(remark.eq(i).val());
//
//                        }
//
//                        var pdsftrxx = $('.wenben-xsd').val();
//                        console.log(pdsftrxx);
//                        if($('.wenben-xsd').val().length===0){
//                            alert('请填写取件信息');
//                            return false;
//                        }
//                        $.ajax({
//                            url:"<?php //echo SITE_PATH ?>//work/bexpress/getOrder",
//                            type:"post",
//                            data:{
//                                'gname':gname,
//                                'gphone':gphone,
//                                'gaddress':gaddress,
//                                'latitude':latitude,
//                                'longitude':longitude,
//                                'remarkArr':remarkArr
//
//                            },
//                            success: function(data){
//                                console.log(data);
//                                if(data.result==1){
//                                    alert('下单成功!');
//                                    //http://s.biandikeji.com/work/borders/untreated
//                                    window.location.href = '<?php //echo SITE_PATH ?>//work/borders/untreated';
//                                }else {
//                                    alert(data.msg);
//                                }
//                            },
//                            error: function(){
//                                alert('提交失败0!');
//                            }
//
//                        })
//
//                    },
//                    cancel: function (res) {
//                        alert('用户拒绝授权获取地理位置');
//                    }
//                });
//            });

        }
        function jx() {
            window.location.href = '<?php echo SITE_PATH ?>work/bpost/jx';
        }
        function sm() {
            window.location.href = '<?php echo SITE_PATH ?>work/bpost/sm';
        }
        function price() {
            window.location.href = '<?php echo SITE_PATH ?>work/bexpress/price';
        }
        function time() {
            window.location.href = '<?php echo SITE_PATH ?>work/bexpress/time';
        }
        function xy() {
            window.location.href = '<?php echo SITE_PATH ?>work/bpost/jxy';
        }
        function dizhi() {
            window.location.href = '<?php echo SITE_PATH ?>work/bexpress/getGood?type=1';
        }

        $('.gongneng').click(function(){
            var bianliang=$(".kuaidigongsi").css("display");
            if(bianliang==="none"){
                $('.kuaidigongsi').css('display','block');
            }else{
                $('.kuaidigongsi').css('display','none');
            }

        });
        $.each($(".kuaidigongsi ul li"),function(index,item){
            $(item).click(function(){
                $(".kuaidigongsi ul li").removeClass("custom_bg");
                $(this).addClass("custom_bg");
            });
        });


        /*单选框切换*/
        var custom_num=0;
        $('.danxuan-btn').click(function(){
            var custom_src=$(this).attr("src");
            var newSrc=custom_src==='<?php echo IMG_PATH ?>bdkd/img/组-@2x.png'?'<?php echo IMG_PATH ?>bdkd/img/组-1@2x.png':'<?php echo IMG_PATH ?>bdkd/img/组-@2x.png';
            console.log(newSrc);
            $(this).attr('src',newSrc);
            custom_num=custom_num===0?1:0;
            console.log(custom_num);
            $(".xyzt").val(custom_num);
            console.log($('.xyzt').val());
        });
        /*单选框切换*/

        $('.wenben-xsd').click(function(){
            $('.wenben-xsd').blur(function(){
//                jianshu();
                var ziduan = $('.wenben-xsd').val();
                console.log(ziduan);
//                qjxxArr.push(ziduan);
//                console.log(qjxxArr);
                if(ziduan.length===0){
                    $('.jiahao').css('display','none');
                    $('.gongji span').html('--');
                    $('.yugu span').html('--');
                }
                if(ziduan.length>0){
                    var i = $('.zjjd a').length;
                    console.log(i);
                    $('.gongji span').html(i);
                    var v = i * 3;
                    $('.yugu span').html(v);
                    $('.jiahao').css('display','block');
                }

            })
        })
        /*添加节点*/
        $('.jiahao').click(function(){
            $('.wenben-xsd').attr('disabled','disabled').css('background','#fff');
            var ipt1=$("<a class='shoujianren qxxhx'><div class='shoujianrenxinxi'><p>请输入您的取件信息<span>( 可直接粘贴 )</span></p><textarea class='xtjd-rjx remark' placeholder='请详细说明快递所在站点名称和取件编码(此处只能填写一条取件信息)' value=''></textarea><img class='img-bug' onclick='add(this)' src='<?php echo IMG_PATH ?>bdkd/img/icon@2x.png' alt=''></div></a>");
            $('.zjjd').append(ipt1);
            var ziduan1 = $('.zjjd a:last .xtjd-rjx').val();
            if(ziduan1.length===0){
                $('.jiahao').css('display','none');
            }
            $('.xtjd-rjx').click(function(){
                $('.xtjd-rjx').blur(function(){
                    var ziduan2 = $('.xtjd-rjx').val();
                    if(ziduan2.length===0){
                        $('.jiahao').css('display','none');
                        $('.zjjd a:last').remove();
                        /*获取添加后的节点个数*/
                        var jdgs = $('.zjjd a').length;
                        console.log(jdgs);
                        if(jdgs===1){
                            $('.wenben-xsd').removeAttr('disabled','disabled').css('background','#fff');
                        }
                    }
                    if(ziduan2.length>0){
                        var h = $('.zjjd a').length;
                        console.log(h);
                        $('.gongji span').html(h);
                        var v = h * 3;
                        $('.yugu span').html(v);
                        $('.jiahao').css('display','block');
                        $('.xtjd-rjx').attr('disabled','disabled').css('background','#fff');
                    }
                })
            })
        });
        function add(a){
            var i =0;
            $('.fucen').css('display','block');
            console.log(a);
            $('.qxdd').click(function(){
                i++;
                if(i===1){
                    $(a).parent().parent().remove();
                    $('.fucen').css('display','none');
                    var r = $('.zjjd a').length;
                    console.log(r);
                    $('.gongji span').html(r);
                    var v = r * 3;
                    $('.yugu span').html(v);
                }
                i=0;
                var jdgs = $('.zjjd a').length;
                console.log(jdgs);
                if(jdgs=1){
                    $('.wenben-xsd').removeAttr('disabled','disabled').css('background','#fff');
                }
            })
        }
        function guanbi(){
            $('.fucen').css('display','none');
        }


        var foU=document.querySelector(".rjx-fjr1");
        var foU2=document.querySelector(".rjx-fjrxx");
        var g=localStorage;
        var fcanshu = $(" input[ name='num' ] ").val();
        /*var fn=g.getItem('fRjxName1');
        var fd=g.getItem('fRjxDianhua1');
        console.log(fd);
        $('#gname1').val(fn);
        $('#gphone1').val(fd);
        console.log(fn);*/
        if(fcanshu==3){
//            alert(99);
            var fstr="";
            var fn=g.getItem('fRjxName1');
            var fd=g.getItem('fRjxDianhua1');
            fstr+=fn+fd;
            foU.value=fstr;
            foU.style.color='#333';
            var f ="";
            var fx=g.getItem('fRjxDizhi1');
            f+=fx;
            foU2.innerHTML=f;
            foU2.style.color='#333';
            $('#gname1').val(fn);
            $('#gphone1').val(fd);
        }else if(fcanshu==4){
//            alert(1111111111);
            var fstr="";
            var fn=g.getItem('fname');
            var fd=g.getItem('fdianhua');
            fstr+=fn+fd;
            foU.value=fstr;
            foU.style.color='#333';
            var f ="";
            var fx=g.getItem('fxinxi');
            var fxx=g.getItem('fxxxx');

            f+=fxx+fx;
            foU2.innerHTML=f;

            foU2.style.color='#333';
            $('#gname1').val(fn);
            $('#gphone1').val(fd);
        }

    </script>

</body>
</html>